package com.hbnu.exercise.net;

import java.io.*;
import java.net.Socket;



public class TcpClientDemo05
{
    public static void main(String[] args)
    {
        try
        {
            Socket socket = new Socket("127.0.0.1", 8888);

            FileInputStream fileInputStream = new FileInputStream(new File("E:\\newlogo/jpg"));
            OutputStream out = socket.getOutputStream();
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            byte[] bytes = new byte[1024];
            int length = 0;
            while ((length = fileInputStream.read(bytes)) != -1)
            {
                out.write(bytes, 0, length);
            }
            socket.shutdownOutput();

            String result = in.readLine();
            System.out.println(result);

            fileInputStream.close();
            socket.close();
        } catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}